#include <bits/stdc++.h>
using namespace std;
#define int long long

char s[3000006];
int n; set<string> t;
const int p = 998244353;

void dfs(string s) {
	if (t.find(s) != t.end()) return;
	t.insert(s);
	if (s.size() == 0) return;
	for (int i = 0; i < s.size() - 1; ++i) {
		if (s[i] == s[i + 1] || (s[i] == 'B' && s[i + 1] == 'A')) {
			string t;
			for (int j = 0; j < s.size(); ++j)
				if (j != i && j != i + 1) t += s[j];
			dfs(t);
		}
	}
}

signed main() {
	freopen("song.in", "r", stdin);
	freopen("song.out", "w", stdout);
	scanf("%s", s + 1); n = strlen(s + 1);
	bool A = 1;
	for (int i = 1; i < n; ++i) {
		if (s[i] == s[i + 1]) A = 0;
	}
	if (n <= 20) {
		dfs(s + 1);
		cout << t.size() << "\n";
	} else if (A) {
		if (s[1] == 'A') cout << (n - 1) / 2 + 1;
		else cout << n / 2 + 1;
	} else {
		dfs(s + 1);
		cout << t.size() << "\n";
	}
}

